<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});

Route::prefix('v1')
    ->namespace('\App\Http\Controllers\Api')
    ->name('api.v1.')
    ->group(function () {
        // 账号密码登录
        Route::post('authorizations', 'AuthorizationsController@store')
            ->name('authorizations.store');
        // 小程序授权
        Route::post('wx-empower', 'AuthorizationsController@wxEmpower')
            ->name('wx.empower');

        // 登录中间件校验
        Route::middleware('member.auth')->group(function () {
            // 个人中心
            Route::get('member-center', 'MemberController@memberCenter')
                ->name('member-center.index');

            // 修改密码
            Route::post('change-password', 'MemberController@changePassword')
                ->name('change-password.index');

            // 退出登录
            Route::post('logout', 'MemberController@logout')
                ->name('member.logout');

            // 添加下级
            Route::post('add-subordinate', 'MemberController@addSubordinate')
                ->name('add-subordinate.store');

            // 文件上传
            Route::post('update', 'UpdateController@update')
                ->name('update.img');
        });
    });
